package xujiwen.transport.servlet;

import xujiwen.transport.bean.SDDis;
import xujiwen.transport.Mgr.SDDisMgr;

import java.text.SimpleDateFormat;
import java.util.Date;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import xujiwen.transport.util.locker.Password;

/**
 * Servlet implementation class for Servlet: Register
 * 
 */
public class ModifSDDis extends javax.servlet.http.HttpServlet implements
		javax.servlet.Servlet {
	/*
	 * (non-Java-doc)
	 * 
	 * @see javax.servlet.http.HttpServlet#HttpServlet()
	 */
	public ModifSDDis() {
		super();
	}

	/*
	 * (non-Java-doc)
	 * 
	 * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request,
	 *      HttpServletResponse response)
	 */
	@Override
	protected void doGet(final HttpServletRequest request,
			final HttpServletResponse response) throws ServletException,
			IOException {
		// TODO Auto-generated method stub
	}

	/*
	 * (non-Java-doc)
	 * 
	 * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request,
	 *      HttpServletResponse response)
	 */
	@Override
	protected void doPost(final HttpServletRequest request,final HttpServletResponse response) throws ServletException,IOException {
		SDDisMgr sm = new SDDisMgr();
		// 指明编码
		request.setCharacterEncoding("utf-8"); 
		
		//System.out.println(password + "\t" + email + "\t");
		try {
			
			final int sdid = Integer.parseInt(request.getParameter("addsdid"));
			final String entryname = request.getParameter("addentryname");
			///
			//System.out.println(entryname);
			final String exitname = request.getParameter("addexitname");
			///
			//System.out.println(exitname);
			final double dis = Double.parseDouble(request.getParameter("adddis"));
			//final int load = Integer.parseInt(request.getParameter("addload"));
			
			final SDDis sddis = new SDDis();
		
			sddis.setEntryName(entryname);
			sddis.setExitName(exitname);
			sddis.setDis(dis);
			sddis.setSdid(sdid);
			
			sm.Update(sddis);
			System.out.println("修改距离成功");
		} catch(final NumberFormatException nfex){
			//response.sendRedirect("err.jsp");
			System.out.println("提交错误");			
			return ;
		}
		response.sendRedirect("admin/stDisMgr.jsp?searchStr=");
	}
}